#include <stdio.h>
#include "dh.h"

static void test_DH_new_Free_c_00(void)
{
    DH *dh = DH_new_c();
    DH_free_c(dh);
    printf("test_DH_new_Free_c_00 ok\n");
}

static void test_DH_new_Free_c_01(void)
{
    DH *dh = NULL;
    DH_free_c(dh);
    printf("test_DH_new_Free_c_01 ok\n");
}

static void test_DH_size_c_01(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int size_dh = DH_size_c(dh);
    printf("size_dh:  %d\n", size_dh);
    DH_free_c(dh);
    printf("test_DH_size_c_01 ok\n");
}

static void test_DH_generate_parameters_ex_c(void)
{
    DH *dh = DH_new_c();
    int DH_generate_parameters_ex_dh = DH_generate_parameters_ex_c(dh, 11, 22);
    printf("DH_generate_parameters_ex_dh:  %d\n", DH_generate_parameters_ex_dh);
    DH_free_c(dh);
    printf("test_DH_generate_parameters_ex_c ok\n");
}

static void test_DH_check_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int DH_check_dh = DH_check_c(dh, 11);
    printf("DH_check_dh:  %d\n", DH_check_dh);
    DH_free_c(dh);
    printf("test_DH_check_c ok\n");
}

static void test_DH_generate_key_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int DH_generate_key_dh = DH_generate_key_c(dh);
    printf("DH_generate_key_dh:  %d\n", DH_generate_key_dh);
    DH_free_c(dh);
    printf("test_DH_generate_key_c ok\n");
}

static void test_DH_check_pub_key_c(void)
{
    DH *dh = DH_new_c();
    BIGNUM *pub_key = BN_new();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int DH_check_pub_key_dh = DH_check_pub_key_c(dh, pub_key, 22);
    printf("DH_check_pub_key_dh:  %d\n", DH_check_pub_key_dh);
    DH_free_c(dh);
    printf("test_DH_check_pub_key_c ok\n");
}

static void test_DH_compute_key_c(void)
{
    DH *dh = DH_new_c();
    BIGNUM *pub_key = BN_new();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int DH_compute_key_dh = DH_compute_key_c("dh", pub_key, dh);
    printf("DH_compute_key_dh:  %d\n", DH_compute_key_dh);
    DH_free_c(dh);
    printf("test_DH_compute_key_c ok\n");
}

static void test_DH_compute_key_padded_c(void)
{
    DH *dh = DH_new_c();
    BIGNUM *pub_key = BN_new();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int DH_compute_key_padded_dh = DH_compute_key_padded_c("dh", pub_key, dh);
    printf("DH_compute_key_padded_dh:  %d\n", DH_compute_key_padded_dh);
    DH_free_c(dh);
    printf("test_DH_compute_key_padded_c ok\n");
}

static void test_DHparams_print_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int DHparams_print_dh = DHparams_print_c(dh);
    printf("DHparams_print_dh:  %d\n", DHparams_print_dh);
    DH_free_c(dh);
    printf("test_DHparams_print_c ok\n");
}

static void test_DH_get0_p_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    BIGNUM *DH_get0_p_c_bm = DH_get0_p_c(dh);
    DH_free_c(dh);
    printf("test_DH_get0_p_c ok\n");
}

static void test_DH_get0_q_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    BIGNUM *DH_get0_q_c_bm = DH_get0_q_c(dh);
    DH_free_c(dh);
    printf("test_DH_get0_q_c ok\n");
}

static void test_DH_get0_g_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    BIGNUM *DH_get0_g_c_bm = DH_get0_g_c(dh);
    DH_free_c(dh);
    printf("test_DH_get0_g_c ok\n");
}

static void test_DH_get0_priv_key_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    BIGNUM *DH_get0_priv_key_c_bm = DH_get0_priv_key_c(dh);
    DH_free_c(dh);
    printf("test_DH_get0_priv_key_c ok\n");
}

static void test_DH_get0_pub_key_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    BIGNUM *DH_get0_pub_key_c_bm = DH_get0_pub_key_c(dh);
    DH_free_c(dh);
    printf("test_DH_get0_pub_key_c ok\n");
}

static void test_DH_set0_pqg_c(void)
{
    DH *dh = DH_new_c();
    BIGNUM *pub_key0 = BN_new();
    BIGNUM *pub_key1 = BN_new();
    BIGNUM *pub_key2 = BN_new();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int DH_set0_pqg_c_dh = DH_set0_pqg_c(dh, pub_key0, pub_key1, pub_key2);
    printf("DH_set0_pqg_c_dh:  %d\n", DH_set0_pqg_c_dh);
    DH_free_c(dh);
    printf("test_DH_set0_pqg_c ok\n");
}

static void test_DH_set0_key_c(void)
{
    DH *dh = DH_new_c();
    BIGNUM *pub_key0 = BN_new();
    BIGNUM *pub_key1 = BN_new();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int DH_set0_key_dh = DH_set0_key_c(dh, pub_key0, pub_key1);
    printf("DH_set0_key_dh:  %d\n", DH_set0_key_dh);
    DH_free_c(dh);
    printf("test_DH_set0_key_c ok\n");
}

static void test_PEM_write_bio_DHparams_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    int PEM_write_bio_DHparams_dh = PEM_write_bio_DHparams_c("pub_key0", "pub_key1", dh);
    printf("PEM_write_bio_DHparams_dh:  %d\n", PEM_write_bio_DHparams_dh);
    DH_free_c(dh);
    printf("test_PEM_write_bio_DHparams_c ok\n");
}

static void test_PEM_read_bio_DHparams_c(void)
{
    DH *dh = DH_new_c();
    DH_generate_parameters_ex_c(dh, 11, 22);
    DH *PEM_read_bio_DHparams_dh = PEM_read_bio_DHparams_c("pub_key0", "pub_key1");
    DH_free_c(dh);
    printf("test_PEM_read_bio_DHparams_c ok\n");
}


void dh_setup_tests(void)
{

    test_DH_new_Free_c_00();
    test_DH_new_Free_c_01();
    test_DH_size_c_01();
    test_DH_generate_parameters_ex_c();
    test_DH_check_c();
    test_DH_generate_key_c();
    test_DH_check_pub_key_c();
    test_DH_compute_key_c();
    test_DH_compute_key_padded_c();
    test_DHparams_print_c();
    test_DH_get0_p_c();
    test_DH_get0_q_c();
    test_DH_get0_g_c();
    test_DH_get0_priv_key_c();
    test_DH_get0_pub_key_c();
    test_DH_set0_pqg_c();
    test_DH_set0_key_c();
    test_PEM_write_bio_DHparams_c();
    test_PEM_read_bio_DHparams_c();
    
    printf("dh_setup_tests over  ok!\n");
    
    
}